package org.fang.service;

import feign.hystrix.FallbackFactory;
import org.fang.common.PlatformResult;
import org.fang.pojo.CloudUser;
import org.springframework.stereotype.Component;
/**
 * @Author forsake
 * @Description  服务降级
 * @Date 10:32 2022/3/11
 **/
@Component
public class UserFallbackFactory implements FallbackFactory {
    @Override
    public UserClientService create(Throwable throwable) {
        return new UserClientService() {
            @Override
            public PlatformResult queryById(Integer id) {
                return PlatformResult.success(new CloudUser().setUsername("改服务已经关闭,服务降级"));
            }

            @Override
            public PlatformResult add(CloudUser user) {
                return null;
            }
        };
    }
}
